//
// Created by luolijun on 2021/10/31.
//

#ifndef DIAGRAMEDITORWIDGET_H
#define DIAGRAMEDITORWIDGET_H

#include "FalconDocument.h"
#include "falcon/facade.h"

#include <QGraphicsView>
#include <QRubberBand>

namespace falcon {

class DiagramEditorWidget : public QGraphicsView {
    Q_OBJECT
public:
    DiagramEditorWidget(QWidget* parent = nullptr);

    void attach(FalconDocument* doc, Package* pkg, Diagram* dag);

public: //  QGraphicsView
    virtual void mousePressEvent(QMouseEvent* event) override;
    virtual void mouseMoveEvent(QMouseEvent* event) override;
    virtual void mouseReleaseEvent(QMouseEvent* event) override;

private:
    void addFacade(POINT pos, Facade* f);
    void delFacade(Facade* f);

private:
    FalconDocument* falconDocument { nullptr };
    Package* package { nullptr };
    Diagram* diagram { nullptr };

    QRubberBand* rubberBand { nullptr };
    QPoint origin;
};
} // namespace falcon

#endif // DIAGRAMEDITORWIDGET_H
